package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ScrapAcceRecordDao;
import com.sugon.entity.ScrapAcceRecordEntity;
import com.sugon.service.ScrapAcceRecordService;
import com.sugon.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.sugon.utils.ShiroUtils.getUserId;

/**
 * ${comments}Service实现类
 *
 * @author sugon
 * @date 2019-07-12 08:50:23
 */
@Service("scrapAcceRecordService")
public class ScrapAcceRecordServiceImpl implements ScrapAcceRecordService {
    @Autowired
    private ScrapAcceRecordDao scrapAcceRecordDao;

    @Override
    public ScrapAcceRecordEntity queryObject(String id) {
        return scrapAcceRecordDao.queryObject(id);
    }

    @Override
    public List<ScrapAcceRecordEntity> queryList(Map<String, Object> map) {
        return scrapAcceRecordDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return scrapAcceRecordDao.queryTotal(map);
    }

    @Override
    public int save(ScrapAcceRecordEntity scrapAcceRecord) {
        scrapAcceRecord.setId(RandomUtil.randomString(32));
        scrapAcceRecord.setDelFlag(Integer.valueOf(Constant.IS_NOT_DEL));
        scrapAcceRecord.setCreateDate(new Date());
        scrapAcceRecord.setCreateUser(getUserId());
        return scrapAcceRecordDao.save(scrapAcceRecord);
    }

    @Override
    public int update(ScrapAcceRecordEntity scrapAcceRecord) {
        scrapAcceRecord.setUpdateDate(new Date());
        scrapAcceRecord.setUpdateUser(getUserId());
        return scrapAcceRecordDao.update(scrapAcceRecord);
    }

    @Override
    public int delete(String id) {
        return scrapAcceRecordDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return scrapAcceRecordDao.deleteBatch(ids);
    }
}
